﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;
using ZR.Service.Service.ProductionControl;

//创建时间：2025-11-04
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 钎焊记录
    /// </summary>
    [Verify]
    [Route("business/CksBrazingRecord")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksBrazingRecordController : BaseController
    {
        /// <summary>
        /// 钎焊记录接口
        /// </summary>
        private readonly ICksBrazingRecordService _CksBrazingRecordService;

        public CksBrazingRecordController(ICksBrazingRecordService CksBrazingRecordService)
        {
            _CksBrazingRecordService = CksBrazingRecordService;
        }

        /// <summary>
        /// 查询钎焊记录列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:list")]
        public IActionResult QueryCksBrazingRecord([FromQuery] CksBrazingRecordQueryDto parm)
        {
            var response = _CksBrazingRecordService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询钎焊记录详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:query")]
        public IActionResult GetCksBrazingRecord(long Id)
        {
            var response = _CksBrazingRecordService.GetInfo(Id);

            var info = response.Adapt<CksBrazingRecordDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加钎焊记录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:add")]
        [Log(Title = "钎焊记录", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksBrazingRecord([FromBody] CksBrazingRecordDto parm)
        {
            var modal = parm.Adapt<CksBrazingRecord>().ToCreate(HttpContext);

            var response = _CksBrazingRecordService.AddCksBrazingRecord(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新钎焊记录
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:edit")]
        [Log(Title = "钎焊记录", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksBrazingRecord([FromBody] CksBrazingRecordDto parm)
        {
            var modal = parm.Adapt<CksBrazingRecord>().ToUpdate(HttpContext);
            var response = _CksBrazingRecordService.UpdateCksBrazingRecord(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除钎焊记录
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:delete")]
        [Log(Title = "钎焊记录", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksBrazingRecord([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_CksBrazingRecordService.Delete(idArr));
        }

        [HttpPost("GetDegrees")]
        [ActionPermissionFilter(Permission = "cksbrazingrecord:list")]
        public IActionResult GetDegrees([FromBody] CksBrazingRecordQueryDto parm)
        {
            var response = _CksBrazingRecordService.GetDegrees(parm);
            return SUCCESS(response);
        }

    }
}